from sklearn.decomposition import PCA, TruncatedSVD


def reduce_to_k_dim(data, reduced_dimension, method="pca"):
    model = None
    if method == "pca":
        model = PCA(n_components=reduced_dimension)
    if method == "svd":
        model = TruncatedSVD(n_components=reduced_dimension)
    # svd = TruncatedSVD(n_components=k)
    # data_reduced = svd.fit_transform(data)

    data_reduced = model.fit_transform(data)
    return data_reduced

